package org.jsola.hr.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.jsola.admin.vo.AllPermissionVO;
import org.jsola.core.Result;
import org.jsola.hr.dto.permission.RoleMemberAddDTO;
import org.jsola.hr.dto.permission.RoleMemberUpdateDTO;
import org.jsola.hr.dto.permission.UpdateRoleDTO;
import org.jsola.hr.query.permission.RoleMemberQuery;
import org.jsola.hr.vo.permission.RoleMemberVO;
import org.jsola.permission.dto.*;
import org.jsola.permission.query.RoleQuery;
import org.jsola.permission.vo.RoleListVO;
import org.jsola.permission.vo.RoleRightListVO;
import org.jsola.permission.vo.RoleVO;

import java.util.List;

/**
 * @author JanusMix
 */
@Api(tags = "hr-权限")
public interface IPermissionControllerAPI {

    /**
     * 用户权限列表
     *
     * @return AllPermissionVO
     */
    @ApiOperation(value = "获取用户所有权限")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", value = "公司id", dataType = "String", paramType = "query"),
    })
    Result<AllPermissionVO> listUserPermission(String companyId);

    /**
     * 用户权限列表2 离职查询
     *
     * @return AllPermissionVO
     */
    @ApiOperation(value = "获取用户所有权限")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", value = "公司id", dataType = "String", paramType = "query"),
    })
    Result<AllPermissionVO> listUserPermission2(String companyId);

    /**
     * 用户权限列表2 小程序登录使用 查询站点需要有员工
     *
     * @return AllPermissionVO
     */
    @ApiOperation(value = "获取用户所有权限")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", value = "公司id", dataType = "String", paramType = "query"),
    })
    Result<AllPermissionVO> listUserPermissionForApp(String companyId);

    @ApiOperation(value = "查询角色列表，返回实体RoleListVO")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleQuery", value = "查询对象", dataType = "RoleQuery", paramType = "query"),
    })
    Result<List<RoleListVO>> queryRoleList(RoleQuery roleQuery);

    @ApiOperation(value = "新增角色")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleAddDTO", value = "新增角色DTO", dataType = "RoleAddDTO", paramType = "body", required = true),
    })
    Result<String> addRole(RoleAddDTO roleAddDTO);

    @ApiOperation(value = "修改角色")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "updateRoleDTO", value = "修改角色DTO", dataType = "UpdateRoleDTO", paramType = "body", required = true),
    })
    Result<String> updateRole(UpdateRoleDTO updateRoleDTO);

    @ApiOperation(value = "删除角色")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleIds", value = "角色id数组", dataType = "Long", paramType = "body", allowMultiple = true, required = true),
    })
    Result<String> deleteRoles(Long[] roleIds);

    /**
     * 根据角色id查询角色详情
     *
     * @param roleId 角色id
     * @return 角色详情
     */
    @ApiOperation(value = "根据角色id查询角色详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleId", dataType = "Long", value = "角色id", paramType = "path")
    })
    Result<RoleVO> findById(Long roleId);

    @ApiOperation(value = "查询角色权限列表，返回实体RoleRightListVO")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "subjectType", value = "业务类型", dataType = "string", paramType = "query", required = true),
            @ApiImplicitParam(name = "roleId", value = "角色id", dataType = "long", paramType = "query", required = true),
    })
    Result<List<RoleRightListVO>> queryRightList(String subjectType, Long roleId);

    @ApiOperation(value = "保存角色权限")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleRightDTOs", value = "角色权限", dataType = "RoleRightAddDTO", paramType = "body", required = true),
    })
    Result<String> saveRoleRight(List<RoleRightAddDTO> roleRightDTOs);

    @ApiOperation(value = "查询当前公司的成员列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleMemberQuery", value = "成员查询对象", dataType = "RoleMemberQuery", paramType = "query", required = true),
    })
    Result<List<RoleMemberVO>> queryRoleMembers(RoleMemberQuery roleMemberQuery);

    @ApiOperation(value = "新增公司成员")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleMemberAddDTO", value = "新增成员对象", dataType = "RoleMemberAddDTO", paramType = "body", required = true),
    })
    Result<String> addRoleMember(RoleMemberAddDTO roleMemberAddDTO);

    @ApiOperation(value = "删除公司成员")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", value = "公司id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "memberIds", value = "成员id串，逗号隔开", dataType = "string", paramType = "query", required = true),
    })
    Result<String> deleteRoleMember(String companyId, String memberIds);

    @ApiOperation(value = "修改公司成员角色")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleMemberUpdateDTO", value = "修改成员对象", dataType = "RoleMemberUpdateDTO", paramType = "body", required = true),
    })
    Result<String> updateRoleMember(RoleMemberUpdateDTO roleMemberUpdateDTO);

}
